﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;
using RuleCode.Table;

namespace map.member
{
    public partial class configshop_search : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (this.Request.Params["keyword"] != null)
                {
                    this.TextBox_key.Text = this.Request.Params["keyword"].ToString();
                }
                //string id = AliApi.appUserId;
                //if (Request.Params["id"] != null)
                //{
                //    cbuser u = cbuser.Find(" recid =  " + Request.Params["id"].ToString());
                //    if (u.Count > 0)
                //    {
                //        id = u.cbuserid.ToString();
                //    }
                //}
                cbuser u = cbuser.getcuruser();
                string id = u.cbuserid.ToString();
                cbshopcss sc = cbshopcss.findorcreate(id);
                string css = sc.getstylestring();
                Literalcss.Text = css;
            }
        }

        protected void Button_search_Click(object sender, EventArgs e)
        {
            string id = AliApi.appUserId;
            if (Request.Params["id"] != null)
            {
                cbuser u = cbuser.Find(" recid =  " + Request.Params["id"].ToString());
                if (u.Count > 0)
                {
                    id = u.cbuserid.ToString();
                }
            }

            cbuser u2 = cbuser.Find("cbuserid = '" + id + "'");
            string url = ResolveUrl("~/member/default.aspx?cbshoppageid=9&id="
                + u2.RECID.ToString() + "&keyword=" + Server.UrlEncode(this.TextBox_key.Text)  
                );
            //string url = ResolveUrl("~/member/default.aspx");
            ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "hasSelected",
                    "<script type =\"text/javascript\" >redirect('" + url + "');</script>", false);
        }
    }
}
